#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=1e5+1000;
typedef int LL;
typedef pair<LL,LL>P;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
LL sum[maxn];
LL cnt[maxn];
LL vis[maxn];
int main(void){
   cin.tie(0);std::ios::sync_with_stdio(false);
   LL n;cin>>n;
   for(LL i=1;i<=n;i++){
       LL x;cin>>x;
       queue<P>que;
       que.push({x,0});
       while(!que.empty()){
            P now=que.front();
            LL x=now.first;LL step=now.second;que.pop();
            if(x>1e5+100) continue;
            if(vis[x]==i) continue;
            vis[x]=i;
            sum[x]+=step;
            cnt[x]++;

            if(x) que.push({x*2,step+1});
            if(x) que.push({x/2,step+1});
       }
   }
   LL ans=0x3f3f3f3f;
   for(LL i=0;i<maxn;i++){
       if(cnt[i]==n){
          ans=min(ans,sum[i]);
       }
   }
   cout<<ans<<"\n";
   return 0;
}
